package hexgame;

import network.RemotePlayer;

/**
 * Stores information about a recieved Hex game request
 * @author Adam
 */
public class HexGameRequest {
	
	/**
	 * Create a new game request.
	 * The created game request must still have the player factory added
	 * @param remotePlayer - The remote player should be connected
	 * @param boardSize - Size of the board should be more than 0. If the local player will be UI, the max size is 11.
	 * @param remotePlayerFirst - Should the remotePlayer take the first turn?
	 * @param didSend - Did we make the request object from creating a new socket? (or accepting a connection?)
	 */
	public HexGameRequest(RemotePlayer remotePlayer, int boardSize, boolean remotePlayerFirst, boolean didSend) {
		this.remotePlayer = remotePlayer;
		this.boardSize = boardSize;
		this.remotePlayerFirst = remotePlayerFirst;
		this.didSendRequest = didSend;
	}
	
	/**
	 * Create a new game request.
	 * The created game request must still have the player factory added
	 * @param remotePlayer - The remote player should be connected
	 * @param boardSize - Size of the board should be more than 0. If the local player will be UI, the max size is 11.
	 * @param remotePlayerFirst - Should the remotePlayer take the first turn?
	 * @param didSend - Did we make the request object from creating a new socket? (or accepting a connection?)
	 * @param observer - Points to an observer player (UI most likely)
	 */
	public HexGameRequest(RemotePlayer remotePlayer, int boardSize, boolean remotePlayerFirst, boolean didSend, PlayerFactory observer) {
		this(remotePlayer, boardSize, remotePlayerFirst, didSend);

		setObserverFactory(observer);
	}
	
	/**
	 * Sets the player factory to be used to create the local player
	 * Must be called before using this request in a HexGame
	 * @param localPlayer - the player factory
	 */
	public void setLocalPlayerFactory(PlayerFactory localPlayer) {
		this.localPlayerFactory = localPlayer;
	}
	
	/**
	 * Sets the observer player
	 * Must be called before using this request in a HexGame if you want an observer
	 * @param observer - the observer player
	 */
	public void setObserverFactory(PlayerFactory observer) {
		this.observerFactory = observer;
	}
	
	public RemotePlayer remotePlayer;
	public PlayerFactory observerFactory;
	public PlayerFactory localPlayerFactory;
	public boolean remotePlayerFirst;
	public int boardSize;
	public boolean didSendRequest;
}
